package demo04_Singleton;

import demo04_Singleton.LoadBalancer.DoubleCheckLazySingleon;
import demo04_Singleton.LoadBalancer.HungrySingleton;
import demo04_Singleton.LoadBalancer.IoDHSingleton;

/**
 * 分别使用饿汉式单例、带双重检查锁定机制的懒汉式单例以及IoDH技术实现负载均衡器
 * LoadBalancer。
 */
public class Singleton01 {


    public static void main(String[] args) {

        HungrySingleton hungrySingleton1 = HungrySingleton.getInstance();
        HungrySingleton hungrySingleton2 = HungrySingleton.getInstance();

        System.out.println(hungrySingleton1 == hungrySingleton2);

        DoubleCheckLazySingleon doubleCheckLazySingleon1 = DoubleCheckLazySingleon.getInstance();
        DoubleCheckLazySingleon doubleCheckLazySingleon2 = DoubleCheckLazySingleon.getInstance();
        System.out.println(doubleCheckLazySingleon1 == doubleCheckLazySingleon2);

        IoDHSingleton ioDHSingleton1 = IoDHSingleton.getInstance();
        IoDHSingleton ioDHSingleton2 = IoDHSingleton.getInstance();

        System.out.println(ioDHSingleton1 == ioDHSingleton2);
    }

}
